/**
 * Created by Administrator on 2017/9/20.
 */
angular.module('service.set', [
        "ngResource",
    ])
    .service('SetService', SetService);
SetService.$inject = ['$resource'];
function SetService($resource) {

    // 开关机时间添加
    this.saveTime = function (time, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming");
        return resource.save(time, success, error);
    };

    // 开关机时间修改
    this.updateTime = function (time, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming/:shopid");
        return resource.save({shopid: time.shopid}, time, success, error);
    };

    // 开关机时间读取
    this.getTime = function (shopid, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming/:shopid");
        return resource.query({shopid: shopid}, success, error);
    };

    // 一键开关机设置
    this.autoSet = function (shopid, alarm, open, close, success, error) {
        var resource = $resource(foodinfoUrl + "condev/:shopid");
        return resource.save({shopid: shopid, alarm: alarm, open: open, close: close}, success, error);
    };

    // 根据shopid获取店铺信息
    this.getShopinfo = function (shopid, success, error) {
        var resource = $resource(merchanturl + "shopinfo/:shopid");
        return resource.get({shopid: shopid}, success, error);
    };

    // 低电量预警设置
    this.setLowPower = function (data, success, error) {
        var resource = $resource(merchanturl + "shopinfo/:shopid");
        return resource.save({shopid: data.shopid}, data, success, error);
    };

    // 通过timeingid修改设置的营业时间
    this.alertTime = function (data, success, error) {
        console.log(data);
        var resource = $resource(foodinfoUrl + "shoptiming/:timeingid");
        return resource.save({timeingid: data.timeingid}, data, success, error)
    };

    // 通过timeingid获取营业时间
    this.getTimeByTimeingid = function (timeingid, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming/timeingid/:timeingid");
        return resource.get({timeingid: timeingid}, success, error)
    };

    // 添加营业时间
    this.addTime = function (data, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming");
        return resource.save(data, success, error);
    };

    //通过timeingid删除营业时间
    this.deleteTime = function (timeingid, success, error) {
        var resource = $resource(foodinfoUrl + "shoptiming/:timeingid");
        return resource.remove({timeingid: timeingid}, success, error);
    };

    // 设置店铺收款码
    this.setShopPay = function (shoppay, success, error) {
        var resource = $resource(merchanturl + "shoppay");
        return resource.save(shoppay, success, error);
    };

    // 获取店铺支付二维码
    this.getShopPay = function (shopid, success, error) {
        var resource = $resource(merchanturl + "shoppay/:shopid");
        return resource.query({shopid: shopid}, success, error);
    };

    // 更新店铺支付二维码
    this.updateShopPay = function (shoppay, success, error) {
        var resource = $resource(merchanturl + "shoppay/:shopid/:createtime");
        return resource.save({shopid: shoppay.shopid, createtime: shoppay.createtime}, shoppay, success, error);
    };

    // 移除店铺支付二维码
    this.removeShopPay = function (shoppay, success, error) {
        var resource = $resource(merchanturl + "shoppay/:shopid/:createtime");
        return resource.remove({shopid: shoppay.shopid, createtime: shoppay.createtime}, shoppay, success, error);
    };
}